using System;
using System.Reflection;
using System.Windows.Forms;
using CuteSprite.Eme.UI.Logon;
using HmFramework;
using HmFramework.IO;
using HmFramework.Log;
using HmFramework.Threading;
using ResManagerUtils = CuteSprite.Eme.UI.Utils.Resources.ResManager;

namespace CuteSprite.Eme.Client.UI
{
	/// <summary>Application main class.</summary>
	public class MainX
	{
		#region static method Main

		/// <summary>The main entry point for the application.</summary>
		[STAThread]
		public static void Main()
		{
			try
			{
				HmTrace.UseWinForm();

				new TimerX(s => Runtime.ReleaseMemory(), null, 5000, 10000);
			}
			catch (Exception ex)
			{
				HmTrace.WriteException(ex);
			}

			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			//Application.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

#if DEBUG
			MISUtils.IsDevelopmentModel = true;
#else
			MISUtils.IsDevelopmentModel = false;
#endif

			ResManagerUtils.LogoIcon = FileSource.GetIcon(Assembly.GetExecutingAssembly(), "logo.ico", 32);

			var frmLogon = FrmLogon.Create(LogOnSystemType.MIS);
			frmLogon.ShowDialog();
			if (frmLogon.DialogResult == DialogResult.OK)
			{
				var frmMain = new MainForm(frmLogon.MisManagement);
				frmLogon.StartPosition = FormStartPosition.CenterParent;
				Application.Run(frmMain);
			}

		}

		#endregion
	}
}
